package coreservice

import (
	"core/corestruct"
	"gorm.io/gorm"
)

type ListService[T any] struct {
}

func (p *ListService[T]) List(ctx *corestruct.HttpContext, db *gorm.DB) (*[]T, error) {
	r := make([]T, 0)
	tx := db.Find(&r)

	if tx.Error != nil {
		return nil, tx.Error
	}

	return &r, nil
}
